home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / espial.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  5KB  |  169 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13.  
  14. unsigned char *espial_attributeram;
  15. unsigned char *espial_column_scroll;
  16.  
  17.  
  18.  
  19. /***************************************************************************
  20.  
  21.   Convert the color PROMs into a more useable format.
  22.  
  23.   Espial has two 256x4 palette PROMs.
  24.  
  25.   I don't know for sure how the palette PROMs are connected to the RGB
  26.   output, but it's probably the usual:
  27.  
  28.   bit 3 -- 220 ohm resistor  -- BLUE
  29.         -- 470 ohm resistor  -- BLUE
  30.         -- 220 ohm resistor  -- GREEN
  31.   bit 0 -- 470 ohm resistor  -- GREEN
  32.   bit 3 -- 1  kohm resistor  -- GREEN
  33.         -- 220 ohm resistor  -- RED
  34.         -- 470 ohm resistor  -- RED
  35.   bit 0 -- 1  kohm resistor  -- RED
  36.  
  37. ***************************************************************************/
  38. void espial_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  39. {
  40.     int i;
  41.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  42.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
  43.  
  44.  
  45.     for (i = 0;i < Machine->drv->total_colors;i++)
  46.     {
  47.         int bit0,bit1,bit2;
  48.  
  49.  
  50.         /* red component */
  51.         bit0 = (color_prom[0] >> 0) & 0x01;
  52.         bit1 = (color_prom[0] >> 1) & 0x01;
  53.         bit2 = (color_prom[0] >> 2) & 0x01;
  54.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  55.         /* green component */
  56.         bit0 = (color_prom[0] >> 3) & 0x01;
  57.         bit1 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
  58.         bit2 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
  59.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  60.         /* blue component */
  61.         bit0 = 0;
  62.         bit1 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
  63.         bit2 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
  64.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  65.  
  66.         color_prom++;
  67.     }
  68. }
  69.  
  70.  
  71.  
  72. WRITE_HANDLER( espial_attributeram_w )
  73. {
  74.     if (espial_attributeram[offset] != data)
  75.     {
  76.         espial_attributeram[offset] = data;
  77.         memset(dirtybuffer,1,videoram_size);
  78.     }
  79. }
  80.  
  81.  
  82.  
  83. /***************************************************************************
  84.  
  85.   Draw the game screen in the given osd_bitmap.
  86.   Do NOT call osd_update_display() from this function, it will be called by
  87.   the main emulation engine.
  88.  
  89. ***************************************************************************/
  90. void espial_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  91. {
  92.     int offs;
  93.  
  94.  
  95.     /* for every character in the Video RAM, check if it has been modified */
  96.     /* since last time and update it accordingly. */
  97.     for (offs = videoram_size - 1;offs >= 0;offs--)
  98.     {
  99.         if (dirtybuffer[offs])
  100.         {
  101.             int sx,sy;
  102.  
  103.  
  104.             dirtybuffer[offs] = 0;
  105.  
  106.             sx = offs % 32;
  107.             sy = offs / 32;
  108.  
  109.             drawgfx(tmpbitmap,Machine->gfx[0],
  110.                     videoram[offs] + 256*(espial_attributeram[offs] & 0x03),
  111.                     colorram[offs],
  112.                     espial_attributeram[offs] & 0x04,espial_attributeram[offs] & 0x08,
  113.                     8*sx,8*sy,
  114.                     0,TRANSPARENCY_NONE,0);
  115.         }
  116.     }
  117.  
  118.  
  119.     /* copy the temporary bitmap to the screen */
  120.     {
  121.         int scroll[32];
  122.  
  123.  
  124.         for (offs = 0;offs < 32;offs++)
  125.             scroll[offs] = -espial_column_scroll[offs];
  126.  
  127.         copyscrollbitmap(bitmap,tmpbitmap,0,0,32,scroll,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  128.     }
  129.  
  130.  
  131.     /* Draw the sprites. Note that it is important to draw them exactly in this */
  132.     /* order, to have the correct priorities. */
  133.     for (offs = 0;offs < spriteram_size/2;offs++)
  134.     {
  135.         int sx,sy,code,color,flipx,flipy;
  136.  
  137.  
  138.         sx = spriteram[offs + 16];
  139.         sy = 240 - spriteram_2[offs];
  140.         code = spriteram[offs] >> 1;
  141.         color = spriteram_2[offs + 16];
  142.         flipx = spriteram_3[offs] & 0x04;
  143.         flipy = spriteram_3[offs] & 0x08;
  144.  
  145.         if (spriteram[offs] & 1)    /* double height */
  146.         {
  147.             drawgfx(bitmap,Machine->gfx[1],
  148.                     code,
  149.                     color,
  150.                     flipx,flipy,
  151.                     sx,sy - 16,
  152.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  153.             drawgfx(bitmap,Machine->gfx[1],
  154.                     code + 1,
  155.                     color,
  156.                     flipx,flipy,
  157.                     sx,sy,
  158.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  159.         }
  160.         else
  161.             drawgfx(bitmap,Machine->gfx[1],
  162.                     code,
  163.                     color,
  164.                     flipx,flipy,
  165.                     sx,sy,
  166.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  167.     }
  168. }
  169.